package edu.scu.declaresys.service.impl;

import java.util.List;

import edu.scu.declaresys.dao.DAOFactory;
import edu.scu.declaresys.dao.intr.IProjectClassDAO;
import edu.scu.declaresys.dao.util.Depth;
import edu.scu.declaresys.exception.ExecuteException;
import edu.scu.declaresys.service.intr.IProjectClassService;
import edu.scu.declaresys.vo.ProjectClass;

/**
 * 
 * @author: zt
 * @since : 2013-7-10
 */
public class ProjectClassServiceImpl implements IProjectClassService
{
	private IProjectClassDAO projectClassDAO = DAOFactory.createProjectClassDAO();

	
	@Override
	public void deleteClass(Integer classId) throws ExecuteException
	{
		projectClassDAO.delete(classId);
	}

	@Override
	public Integer addClass(ProjectClass vo) throws ExecuteException
	{
		return projectClassDAO.save(vo);
	}

	@Override
	public void modifyClass(ProjectClass vo) throws ExecuteException
	{
		projectClassDAO.update(vo, vo.getId());
	}
	
	@Override
	public List<ProjectClass> findClassList() throws ExecuteException
	{
		return projectClassDAO.findByProperty(null, null, Depth.ZERO, null, null, null, null);
	}

	@Override
	public ProjectClass findClass(Integer classId) throws ExecuteException
	{
		return projectClassDAO.findById(classId, Depth.ZERO);
	}
	
	@Override
	public ProjectClass findClassByName(String className) throws ExecuteException
	{
		return projectClassDAO.findByPropertyUnique(ProjectClass.T_NAME, className, Depth.ZERO);
	}
	
}
